package com.choudou5.solr.util;

import cn.hutool.core.util.RandomUtil;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @name：报表工具类
 * @author：xuhaowen
 * @date：2018-08-25
 */
public class ReportUtil {

    /**
     * 根据日期类别 获取数据列表
     * @param dateList
     * @param dataList
     * @return
     */
    public static List<Long> getDataListByDateList(List<String> dateList, List<String> dataList) {
        List<Long> result = new ArrayList<>();
        if(CollUtil.isNotEmpty(dataList)){
            Long longVal = null;
            for (String date : dateList) {
                for (String val : dataList) {
                    if(val != null && val.toString().startsWith(date)){
                        longVal = Long.parseLong(StrUtil.subAfter(val.toString(), "=", true));
                        break;
                    }
                }
                if(longVal == null){
                    longVal = 0L;
                }
                result.add(longVal);
            }
        }else{
            for (String date : dateList) {
                result.add(RandomUtil.randomLong(50));
            }
        }
        return result;
    }

}
